package com.woniuxy.dr_mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.dr_mall.entity.DrPicture;
import com.woniuxy.dr_mall.mapper.DrPictureMapper;
import com.woniuxy.dr_mall.service.IDrPictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 张哲轩
 * @since 2021-08-11
 */
@Service
public class DrPictureServiceImpl extends ServiceImpl<DrPictureMapper, DrPicture> implements IDrPictureService {
    @Autowired
    private DrPictureMapper drPictureMapper;
    @Override
    public List<String> getImageByProductId(int productId) {
        return drPictureMapper.getImageByProductId(productId);
    }

    @Override
    public void CommentPictureAdd(DrPicture drPicture) {
        drPictureMapper.CommentPictureAdd(drPicture);
    }

    @Override
    public String[] getCommentImageByCId(int commentId) {
        //List<String>  rPictureMapper.getCommentImageByCId(commentId)
        String[] image = drPictureMapper.getCommentImageByCId(commentId);
        for (int i = 0; i < image.length; i++) {
            String url = image[i];
            String newUrl = "http://localhost:8080/"+url;
            image[i] = newUrl;
        }
        return image;
    }
}
